#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int MAXN=2010,INF=0x7fffffff;
int n,A,B;
LL pre[MAXN],num=(1LL<<41)-1;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
bool check1(LL x)
{
	int f[MAXN];
	memset(f,127,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;++i)
		for(int j=i-1;~j;--j)
			if(((pre[i]-pre[j])|x)<=x&&f[j]+1<f[i])
				f[i]=f[j]+1;
	return f[n]<=B;
}
void solve1()
{
	for(int i=40;~i;--i)
		if(check1(num^(1LL<<i)))num^=(1LL<<i);
	printf("%lld\n",num);
	return;
}
bool check2(LL x)
{
	bool f[MAXN][MAXN];
	memset(f,0,sizeof(f));
	f[0][0]=true;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=min(B,i);++j)
			for(int k=i-1;~k;--k)
				if(((pre[i]-pre[k])|x)<=x&&f[k][j-1])
				{
					f[i][j]=true;
					break;
				}
	for(int i=A;i<=B;++i)if(f[n][i])return true;
	return false;
}
void solve2()
{
	for(int i=40;~i;--i)
		if(check2(num^(1LL<<i)))num^=(1LL<<i);
	printf("%lld\n",num);
	return;
}
int main()
{
	n=read();A=read();B=read();
	for(int i=1;i<=n;++i)pre[i]=read()+pre[i-1];
	if(A==1)solve1();
	else solve2();
	return 0;
}
